<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['product']) && ($_SESSION['product']&1<<1)==0)) {
	Vfriend_Function::redirect(HOST_BACKEND);
}
$intParentId 	= $objRequest->getParam('pparentid',0);
$strName 		= $objRequest->getParam('pname','');
$intDisOrder 	= $objRequest->getParam('pdisorder',0);
$strRefer	 	= $objRequest->getParam('prefer',HOST_BACKEND . 'category/index');
$intError		= 0;
if($strName == '') $intError = 1;
elseif($strName != '' && strlen($strName)<2) $intError = 2;
if($intError == 0) {
	if(isset($_SESSION['cpost'])) unset($_SESSION['cpost']);
	if(isset($_SESSION['cerror'])) unset($_SESSION['cerror']);
	$objCategory = new Category();
	$intError	 = $objCategory->add($AppUI->id, $strName, $intParentId, $intDisOrder);
	if($intError == 0) {
		Vfriend_Function::setMsg($arrMessage[5]);
		Vfriend_Function::redirect($strRefer);
	}
}
if($intError > 0) {
	$_SESSION['cpost']	= $objRequest->getParams();
	$_SESSION['cerror']	= $arrError[$intError];
	Vfriend_Function::redirect(HOST_BACKEND . 'category/add?parentid=' . $intParentId);
}
?>